#ifndef __CMS_LOG_WFP74ATP
#define __CMS_LOG_WFP74ATP

#include <syslog.h>

enum loglevel{
    LL_FATAL = 0,
    LL_ERROR,
    LL_WARNING,
    LL_NOTICE,
    LL_INFO,
    LL_DEBUG,
    LL_SPEW,
    LL_FLOOD,
    LL_PRINT,
};

#define LL_SYSLOG           0x0100
#define LL_SYSLOG_MASK      0x0100
#define LL_LEVEL_MASK       0x000f


#define LL_COLOR_NON        "\033[0m"
#define LL_COLOR_RED        "\033[31m"
#define LL_COLOR_GRE        "\033[32m"
#define LL_COLOR_YEL        "\033[33m"
#define LL_COLOR_BLU        "\033[34m"

#define CMS_LOG_PREFIX      "CMS"
#define CMS_LOG_SUPPORT_MS  1
#define CMS_LOG_MS_FILE     "/tmp/cms_log_ms"


#ifdef SYSDEF_PARSER_ON_HOST
#define CMS_LOG(level, arg, ...) \
    do{ if((level) == LL_ERROR) \
            printf(LL_COLOR_RED"[CMS compile Error]["__FILE__":%d][%s]: "arg LL_COLOR_NON"\n", __LINE__, __FUNCTION__, ##__VA_ARGS__);\
        else \
            printf("[CMS compile Info ]["__FILE__":%d][%s]: "arg"\n", __LINE__, __FUNCTION__, ##__VA_ARGS__);\
    }while(0)
#else
#define CMS_LOG(level, arg...) \
    cms_log_print(__FILE__, __FUNCTION__, __LINE__, level, arg)
#define CMS_SYSLOG(level, arg...) \
    cms_syslog_print(__FILE__, __FUNCTION__, __LINE__, level, arg)
#endif

#define __CMS_LOG(level) cms_log_level_check(level)
    
void log_enable_syslog(void);
void log_disable_syslog(void);
void set_log_level(char *moduleName, int level);
void cms_log_print(const char *fileName, const char *funcName, int lineNum, enum loglevel level, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
void cms_syslog_print(const char *fileName, const char *funcName, int lineNum, int prority, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
int cms_log_level_check(int level);



#endif /* end of include guard: __CMS_LOG_WFP74ATP */
